package demo7;

import java.util.ArrayList;

public class StudentOperation1 implements StudentOperationImp{
    @Override
    public void printAllStudentGrade(ArrayList <Student> students){
        System.out.println("====== 打印全班学生信息 ======");
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("姓名：" + student.getName() + " 性别：" + student.getAge() + " 分数：" + student.getGrade());
        }
        System.out.println("====== 打印全班学生信息 ======");
    }

    @Override
    public void printAverageGrade(ArrayList<Student> students) {
        System.out.println("====== 打印全班平均分数 ======");
        double grade = 0.0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            grade += student.getGrade();
        }
        grade /= students.size();
        System.out.println("班级平均分为：" + grade);
        System.out.println("====== 打印全班平均分数 ======");

    }
}
